package cn.kbblog.biz;

import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.TextMessage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;

import cn.kbblog.dao.UserinfoDao;
import cn.kbblog.entity.Userinfo;

@Component
public class MqMessageHandleBiz {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(MqMessageHandleBiz.class);
	
	@Resource
	private UserinfoDao userDao;
	
	public void updateQueueReceiverMessage(Message arg0) {
        try {
        	TextMessage txtMessage = (TextMessage)arg0;
        	Userinfo user = JSONObject.parseObject(txtMessage.getText(), Userinfo.class);
        	userDao.insert(user);
        } catch (JMSException e) {
            LOGGER.error("error {}", e);
        }
	}
}
